package com.atguigu.gulimall.product.web;

import com.atguigu.gulimall.product.service.SkuInfoService;
import com.atguigu.gulimall.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @Description TODO
 * @Author dingchunlin
 * @Date 2024/1/27 16:43
 * @Version 1.0.0
 */
@Controller
public class ItemController {


    @Autowired
    private SkuInfoService skuInfoService;

    /**
     * 展示当前sku的详情
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId,Model Model) {
        System.out.println("准备查询"+skuId+"详情");
        SkuItemVo itemVo = skuInfoService.item(skuId);
        System.out.println(itemVo.getDesp());
        Model.addAttribute("item",itemVo);
        return "item";
    }
}
